﻿<Application x:Class="DevKnightlie.WPF.AutoForm.Demo.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:DevKnightlie.WPF.AutoForm.Demo"
             xmlns:af="clr-namespace:DevKnightlie.WPF.AutoForm;assembly=DevKnightlie.WPF.AutoForm"
             xmlns:afdefs="clr-namespace:DevKnightlie.WPF.AutoForm.FieldDefinitions;assembly=DevKnightlie.WPF.AutoForm"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <local:PersonDataModel x:Key="SimpleDataModel" />
        <local:PersonDataModel x:Key="SimpleDataModel2" />
        <local:FileProcessDataModel x:Key="FileProcessDataModel" />
        <local:ReportSettingsDataModel x:Key="ReportSettingsDataModel" />
        <local:AdvancedDataModel x:Key="AdvancedDataModel" />
        <af:ModelObjectFormDefiner x:Key="SimpleModelDefiner" 
            ModelObject="{StaticResource SimpleDataModel}" />
        <af:ModelObjectFormDefiner x:Key="SimpleModelDefiner2" 
            ModelObject="{StaticResource SimpleDataModel}" />
        <af:ModelObjectFormDefiner x:Key="FileProcessModelDefiner" 
            ModelObject="{StaticResource FileProcessDataModel}" />
        <af:FieldDefinitionList x:Key="StaticFieldDefinitions">
            <afdefs:HeaderFieldDefinition Title="Basic Fields" StretchMode="Full" />
            <afdefs:TextFieldDefinition 
                PropertyName="ReportTitle" MaxLength="30" />
            <afdefs:FilePickerFieldDefinition 
                PropertyName="OutputFilename" />
            <afdefs:IntegerSpinnerFieldDefinition 
                PropertyName="RowsPerSection" />
            <afdefs:HeaderFieldDefinition Title="Slider and Progress Bar" StretchMode="Full" />
            <afdefs:IntegerSliderFieldDefinition 
                PropertyName="ReportProgress" 
                MinimumValue="0" 
                MaximumValue="10" />
            <afdefs:ProgressBarFieldDefinition 
                PropertyName="ReportProgress" 
                StretchMode="Full" 
                Minimum="0" 
                Maximum="10" 
                ShowLabel="True" 
                IndeterminatePropertyName="Indeterminate"  />
            <afdefs:CheckBoxFieldDefinition 
                PropertyName="Indeterminate" />
        </af:FieldDefinitionList>
        <af:ModelObjectFormDefiner x:Key="AdvancedModelDefiner" 
            ModelObject="{StaticResource AdvancedDataModel}" 
            FieldDefinitionRequired="ModelObjectFormDefiner_FieldDefinitionRequired" 
            FieldDefinitionCreated="ModelObjectFormDefiner_FieldDefinitionCreated" />
        <af:StackedLayoutStrategy x:Key="StackedLayoutStrategy" />
        <!-- Sub-Forms -->
        <af:StackedLayoutStrategy x:Key="SubFormLayoutStrategy" />
        <af:StackedLayoutStrategy x:Key="AddressSubFormLayoutStrategy" />
        <af:StackedLayoutStrategy x:Key="ContactFormLayoutStrategy" /> <!-- We can't currently share layout strategies between forms -->
        <af:FieldDefinitionList x:Key="SubFormInnerFields">
            <afdefs:TextFieldDefinition Title="First name" PropertyName="FirstName" />
            <afdefs:TextFieldDefinition Title="Last name" PropertyName="LastName" />
            <afdefs:DateFieldDefinition Title="Date of Birth" PropertyName="DateOfBirth" />
            <afdefs:StaticTextFieldDefinition Title="" /> <!-- This ensures both sub-forms have the same number of rows -->
        </af:FieldDefinitionList>
        <af:FieldDefinitionList x:Key="SubFormInnerFields2">
            <afdefs:TextFieldDefinition Title="Street" PropertyName="Street" />
            <afdefs:TextFieldDefinition Title="Town" PropertyName="Town" />
            <afdefs:TextFieldDefinition Title="City" PropertyName="City" />
            <afdefs:TextFieldDefinition Title="State" PropertyName="State" />
        </af:FieldDefinitionList>
        <af:FieldDefinitionList x:Key="SubFormInnerFields3">
            <afdefs:TextFieldDefinition Title="Contact telephone" PropertyName="ContactPhone" />
            <afdefs:TextFieldDefinition Title="Contact email" PropertyName="ContactEmail" />
            <afdefs:TextFieldDefinition Title="Preferred name" PropertyName="PreferredName" />
            <afdefs:StaticTextFieldDefinition Title="The name the customer would like to be addressed as" />
        </af:FieldDefinitionList>
        <af:FieldDefinitionList x:Key="SubFormOuterFields">
            <afdefs:TextFieldDefinition Title="Account name" PropertyName="AccountName" />
            <afdefs:TextFieldDefinition Title="Account number" PropertyName="AccountNumber" />
            <afdefs:SubFormFieldDefinition Title="Account Holder Details" 
                                           LayoutStrategy="{StaticResource SubFormLayoutStrategy}" 
                                           FieldDefinitionList="{StaticResource SubFormInnerFields}" />
            <afdefs:SubFormFieldDefinition Title="Account Holder Address" 
                                           LayoutStrategy="{StaticResource AddressSubFormLayoutStrategy}" 
                                           FieldDefinitionList="{StaticResource SubFormInnerFields2}" />
            <afdefs:SubFormFieldDefinition Title="Contact Information"
                                           ContainerType="Expander"
                                           StretchMode="Full"
                                           LayoutStrategy="{StaticResource ContactFormLayoutStrategy}"
                                           FieldDefinitionList="{StaticResource SubFormInnerFields3}" />
        </af:FieldDefinitionList>
    </Application.Resources>
</Application>
